﻿using PDFDesign.Model;

namespace PDFDesign.ViewModel
{
    public class TableViewModel : BaseViewModel
    {
        public TableViewModel(Table table)
        {
            Table = table;
            fixedRowCount = table.FixedRowCount;
            rowCount = table.RowCount;
            renderWhiteRow = table.RenderWhiteRow;
            top = table.Position.Top;
            left = table.Position.Left;
            width = table.Size.Width;
            height = table.Size.Height;
        }

        public Table Table { get; set; }

        public void Save()
        {
            Table.FixedRowCount = fixedRowCount;
            Table.RowCount = rowCount;
            Table.RenderWhiteRow = renderWhiteRow;
            Table.Position.Top = top;
            Table.Position.Left = left;
            Table.Size.Width = width;
            Table.Size.Height = height;
        }

        private bool fixedRowCount;
        public bool FixedRowCount
        {
            get => fixedRowCount;
            set
            {
                fixedRowCount = value;
                OnPropertyChanged("FixedRowCount");
            }
        }

        private int rowCount;
        public int RowCount
        {
            get => rowCount;
            set
            {
                rowCount = value;
                OnPropertyChanged("RowCount");
            }
        }

        private bool renderWhiteRow;
        public bool RenderWhiteRow
        {
            get => renderWhiteRow;
            set
            {
                renderWhiteRow = value;
                OnPropertyChanged("RenderWhiteRow");
            }
        }

        private double top;
        public double Top
        {
            get => top;
            set
            {
                top = value;
                OnPropertyChanged("Top");
            }
        }

        private double left;
        public double Left
        {
            get => left;
            set
            {
                left = value;
                OnPropertyChanged("Left");
            }
        }

        private double width;
        public double Width
        {
            get => width;
            set
            {
                width = value;
                OnPropertyChanged("Width");
            }
        }

        private double height;
        public double Height
        {
            get => height;
            set
            {
                height = value;
                OnPropertyChanged("Height");
            }
        }
    }
}
